{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第一次课作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## （1）python基础语法。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（1）下面两段代码输出的结果相同么？请解释原因。    \n",
    "① x=4，y=5，print（x+y） \n",
    "② x='4',y='5', print(x+y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（2）‘10/3'，‘10//3’和'10%3'结果相同么？请说明原因。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（3）string1='I'm a student.' 。print(string1)结果会报错么？如何修改string1使其得到正确的输出？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（4） a = 3，str(a\\*3) + str(a)\\*3的输出是什么?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（5）my_string = 'this is my string', 如何查看这个字符串长度？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（6）a,b = 4,5,a大于b 或 b大于等于5。请写出这里逻辑运算的代码，并查看输出会是什么。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（7）'='和'=='分别表示什么含义？print(2==5)输出什么结果？属于什么类型数据？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（8）计算：100%(2+2)\\*\\*3//5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（9）a,b = 4,5，a \\*= b，a=? "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（10）int(3.14159)==float(3)会输出什么结果？为什么？type(int(3.14159))==type(float(3))的结果又是什么？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## （2）列表，字典，集合"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（1）L=[1,2,3,4,1,4,5,6],请完成：①删除列表中的重复元素并输出一个集合；②将7添加到集合中；③将集合转化为列表，删除元素3."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（2）dog = [\"tom\", \"jack\", \"Collie\", \"Marry\"], kitty = \"Marry\", 如何判断 kitty 是否是 dog 中的一员?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（3）dog = [\"tom\", \"jack\", \"Collie\", \"Marry\"]，将dog逆序。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（4）L=[\"former\", \"latter\", \"starboard\"]，请完成：为L在末端添加一个元素“port”。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（5）L=[1,2,3,1,5,11,3,6,4,2,5,8,4,2],计算L的最值，和加和。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（6）cube：length：40，width：40，height：40, 请创建一个字典，包括cube的所有信息，并向字典中添加条目“color”和对应值\"red\"，  \n",
    "删除属性height，修改属性width为20."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（7）set_a = {1, 5, 10} set_b = {1, 10, 12} 找出set_a和set_b中共有的元素（交集）。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（8）从1到10中选出所有的奇数。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（9）将字典变为两个元素一一对应的列表，一个只含有关键字，另一个只含有值。 如:{'a': 1, 'b': 2}变为['a', 'b'], [1, 2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## （3）条件判断，循环和函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（1）L=[1,2,'','my',3,'name','is',4,'katty'],利用循环语句和判断条件，分别输出列表中的字符串和数字。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（2）利用循环语句输出1到50中5的倍数，将其存放到一个列表中。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（3）定义一个判断字符串的长度是否大于10的函数。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（4）定义一个求解阶乘的函数。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（5）利用列表生成式，生成1-5的阶乘。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "（6）利用函数和列表生成式，标记一个列表，奇数标记为1，偶数标记为2，并且统计一下奇数和偶数的数量。\n",
    "     例如：[1,4,2,4,2,9,5]，得到[1,2,2,2,2,1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
